import Vue from 'vue'
import VueRouter from 'vue-router'
// 引入Home组件
import Home from '@views/Home'
Vue.use(VueRouter)

const routes = [
  { // 路由重定向，打开浏览器自动打开首页
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: '首页',
    component: Home
  },
  // 除了首页以下页面懒加载
  {
    path: '/cate',
    name: '分类页',
    component: () => import('@views/Cate')
  },
  {
    path: '/cart',
    name: '购物车',
    component: () => import('@views/Cart')
  },
  {
    path: '/user',
    name: '个人中心',
    component: () => import('@views/User')
  },
  {
    path: '/cateItem',
    name: '分类列表',
    component: () => import('@views/CateItem')
  },
  {
    path: '/detail',
    name: '详情页',
    component: () => import('@views/Detail')
  },
  {
    path: '/login',
    name: '登录页',
    component: () => import('@views/Login')
  },
  {
    path: '/registry',
    name: '注册页',
    component: () => import('@views/Registry')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
